#include "utils.h"

#include <unistd.h>


uint32_t reversebytes_uint32t(uint32_t value){
    return (value & 0x000000FFU) << 24 | (value & 0x0000FF00U) << 8 |
        (value & 0x00FF0000U) >> 8 | (value & 0xFF000000U) >> 24;
}

int16_t max(int16_t a, int16_t b)
{
    return a > b ? a : b;
}

int16_t min(int16_t a, int16_t b)
{
    return a < b ? a : b;
}

double max(double a, double b)
{
    return a > b ? a : b;
}

double min(double a, double b)
{
    return a < b ? a : b;
}

double map(double x, double in_min, double in_max, double out_min, double out_max)
{
    return (((double)x - (double)in_min) * ((double)out_max - (double)out_min) / ((double)in_max - (double)in_min) + (double)out_min);
}
